package com.example.smartcity_poverty.ui.AllService.ActivityManAge.adapter

import android.content.Intent
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.model.ActivityManAge.HListModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.AllService.ActivityManAge.activity.ManAgeShowListActivity
import kotlinx.android.synthetic.main.re_activity_manage_list.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *  活动管理列表适配器
 **/
class ActManAgeListAdapter (
    val list: MutableList<HListModel.RowsBean>,
    val layoutId: Int,
    val size: Int
) : BaseRecyclerAdapter<HListModel.RowsBean>(list, layoutId){
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: HListModel.RowsBean,
        position: Int,

        holder: BaseViewHolder
    ) {
        // list.sortBy { it -> it.publishTime }

        val d = list[position]
        val v = holder.viewFind
        val con = v.view?.context

        glide(url + d.imgUrl, v.HImageView)
        v.HTitle.text = d.name
        // v.HContent.text = Html.fromHtml(d.content)
        v.HUserSize.text = "报名人数: ${d.signupNum.toString()}"
        v.HUserUp.text = d.likeNum.toString()

        // 点击事件
        holder.itemView.setOnClickListener {
            con?.startActivity(Intent(con, ManAgeShowListActivity::class.java).putExtra("id", d.id.toString()))
        }
    }

    override fun getItemCount(): Int = size
}